import config from '@/common/config'
import {
	orderStateMap,
	refundStateMap
} from '@/common/orderConfig.js'
module.exports = {
	data() {
		return {}
	},
	props: {

	},
	// 分享
	onShareAppMessage(res) {
		return {
			title: '靓鲸洗生活服务平台',
			path: '/pages/mainPage/homePage/homePage',
			// imageUrl: `${this.imageDomain}/share-image.jpeg`
		}
	},
	onShareTimeline() {
		return {
			title: '靓鲸洗生活服务平台'
		}
	},
	onShow() {

	},
	mounted() {},
	computed: {
		orderStateText() {
			if (this.refundState) {
				const refundState = refundStateMap.find(item => item.value == this.refundState)
				if (refundState) {
					return refundState.label
				}
			}
			if (!this.orderState) {
				return ''
			}
			const state = orderStateMap.find(item => item.value == this.orderState)
			if (state) {
				return state.label
			} else {
				return ''
			}
		}
	},
	methods: {
		getOrderStateText(orderState,refundState) {
			if (refundState) {
				const refund = refundStateMap.find(item => item.value == refundState)
				if (refund) {
					return refund.label
				}
			}
			if (!orderState) {
				return ''
			}
			const state = orderStateMap.find(item => item.value == orderState)
			if (state) {
				return state.label
			} else {
				return ''
			}
		},
		formatDate(date) {
			const year = date.getFullYear();
			const month = ('0' + (date.getMonth() + 1)).slice(-2);
			const day = ('0' + date.getDate()).slice(-2);
			return `${year}-${month}-${day}`;
		},
		formatTime(time) {
			const hour = ('0' + time.getHours()).slice(-2)
			const mm = ('0' + time.getMinutes()).slice(-2)
			const ss = ('0' + time.getSeconds()).slice(-2)
			return `${hour}:${mm}:${ss}`
		},
		initData() {
			this.$u.api['user/getUserInfo']().then(res => {
				console.log(res.data.data)
				this.$u.vuex('userInfo', res.data.data)
			})
			this.$u.api['goods/getFirstGoodsTypeList']().then(res => {
				this.$u.vuex('goodsTypeList', res.data.data)
			})
		},
		logOut() {
			this.$u.vuex('userInfo', '')
			this.$u.vuex('refreshToken', '')
			this.$u.vuex('accessToken', '')
			this.$u.vuex('tokenTime', '')
			this.$u.vuex('openId', '')

			this.$u.route({
				url: '/pages/mainPage/homePage/homePage',
				type: 'tab'
			})
		},
		clearAppData() {
			this.$store.commit('setDataLoadState', false)
		},
	}
}